﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PayPalApp
{
    public partial class Form1 : Form
    {
        PayPal pp;
        String fileName;
        public Form1()
        {
            InitializeComponent();
            fileName = "";
            pp = new PayPal();
        }

        private void btBrowse_Click(object sender, EventArgs e)
        {
            DialogResult dr;
            dr = openFileDialog1.ShowDialog();
            if (dr == DialogResult.OK)
            {  //the user pushed the OK-button of openFileDialog1
                tbFilename.Text = openFileDialog1.FileName;
                fileName = tbFilename.Text;
            }
            else
            {  //the user pushed the CANCEL-button of openFileDialog1
                MessageBox.Show("You pushed the CANCEL-button.");
            }
        }

        private void btReadFile_Click(object sender, EventArgs e)
        {
            if (fileName != "")
            {
                int nr=pp.readFromFile(fileName);
                if (nr == 1)
                {
                    MessageBox.Show("ok");
                }
                else
                {
                    MessageBox.Show("Something went wrong");
                }
            }
            else
            {
                MessageBox.Show("you didn't select a file!");
            }
        }
    }
}
